package io.renren.modules.shop.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.shop.entity.RepertoryEntity;
import io.renren.modules.shop.service.RepertoryService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 *
 *
 * @author Yangqianyong
 * @email sunlightcs@gmail.com
 * @date 2021-11-17 15:35:51
 */
@RestController
@RequestMapping("shop/repertory")
public class RepertoryController {
    @Autowired
    private RepertoryService repertoryService;

    /**
     * 列表
     */
    @RequestMapping("/list")
//    @RequiresPermissions("shop:repertory:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = repertoryService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{repertoryId}")
//    @RequiresPermissions("shop:repertory:info")
    public R info(@PathVariable("repertoryId") Integer repertoryId){
		RepertoryEntity repertory = repertoryService.getById(repertoryId);

        return R.ok().put("repertory", repertory);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
//    @RequiresPermissions("shop:repertory:save")
    public R save(@RequestBody RepertoryEntity repertory){
		repertoryService.save(repertory);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
//    @RequiresPermissions("shop:repertory:update")
    public R update(@RequestBody RepertoryEntity repertory){
		repertoryService.updateById(repertory);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
//    @RequiresPermissions("shop:repertory:delete")
    public R delete(@RequestBody Integer[] repertoryIds){
		repertoryService.removeByIds(Arrays.asList(repertoryIds));

        return R.ok();
    }

}
